import { Controller, Get, Post, Body, Patch, Param, Delete, Query } from "@nestjs/common";
import { RoleService } from "./role.service";
import { CreateRoleDto } from "./dto/create-role.dto";
import { UpdateRoleDto } from "./dto/update-role.dto";
import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger";

@Controller("role")
@ApiTags('角色相关')
@ApiBearerAuth()
export class RoleController {
    constructor(private readonly rolesService: RoleService) {
    }
    
    @Post()
    create(@Body() createRoleDto: CreateRoleDto) {
        return this.rolesService.create(createRoleDto);
    }
    
    @Get()
    findAll(@Query() dto) {
        return this.rolesService.findAll(dto);
    }
    
    @Get('findAllNoPage')
    @ApiOperation({summary:'查询所有用户角色'})
    findAllNoPage(@Query() dto) {
        return this.rolesService.findAllNoPage();
    }
    
    @Get(":id")
    findOne(@Param("id") id: string) {
        return this.rolesService.findOne(+id);
    }
    
    @Patch(":id")
    update(@Param("id") id: string, @Body() updateRoleDto: UpdateRoleDto) {
        return this.rolesService.update(+id, updateRoleDto);
    }
    
    @Delete(":id")
    remove(@Param("id") id: string) {
        return this.rolesService.remove(+id);
    }
    
}
